<template>
    <div>
        <div class="container">
            <el-table :data="newsCatalogTableData" border class="table" header-cell-class-name="table-header" @row-click="func_trClick">>	
                <el-table-column prop="id" label="ID" width="55" align="center" v-if="false" />
				<el-table-column label="序号" width="80" align="center"><template #default="scope">
						{{scope.$index + 1}}
				</template></el-table-column>
                <el-table-column prop="catalogName" label="分类名称" align="left" />
				<el-table-column prop="catalogEnname" label="分类英文字" align="left" />
            </el-table>
            <div class="pagination">
                <el-pagination background layout="total, prev, pager, next" :current-page="query.pageNum"
                    :page-size="query.pageSize" :total="dataTotal" @current-change="func_handlePageChange"></el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useRouter, useRoute } from 'vue-router';
import { ElMessage, ElMessageBox } from "element-plus";
import { findNewsCatalogListPage, batchIsShow, batchIsSplit, } from "../../../../api/hairmanager/newsCatalog";

export default {
    name: "newsCatalog",
    components: {},
    setup(props, cex){
        const router = useRouter();
		const route = useRoute();
        //主数据条件查询
        const query = reactive({
            keyword: "",
			groupId: 0,
            pageIndex: 1,
            pageSize: 10,
        });
        // 主数据总页数
        const dataTotal = ref(0);
        // 主数据表格
        let newsCatalogTableData = ref([]);
        // =========================================================================================
        // 主业务处理 ========================================================================================= START
        /**
         * @name 获取表格数据
         */
        const func_getData = () => {
            findNewsCatalogListPage(query).then((res) => {
                newsCatalogTableData.value = res.data.list;
                dataTotal.value = res.data.total;
            });
        };
        func_getData();
        /**
         * @name 主数据查询操作
         */
        const func_handleSearch = () => {
            query.pageNum = 1;
            func_getData();
        };
        /**
         * @name 分页导航
         */
        const func_handlePageChange = (val) => {
            // query.pageIndex = val;
            query['pageNum'] = val;
            func_getData();
        };
		const func_trClick = (row,event,column) =>{
			cex.emit('dictData',  {dicCode:row['id'], dicName:row['catalogName']});
		};
        // 主业务处理 ========================================================================================= END
        // 业务插件处理 ========================================================================================= START
        // 业务插件处理 ========================================================================================= END
        return {
            // 系统环境变量
            query, dataTotal,
            // 主业务处理
            func_getData, newsCatalogTableData, func_handleSearch, func_handlePageChange, func_trClick,
        };
    },
};
</script>
<style scoped>
.handle-box {
    margin-bottom: 20px;
}
.handle-select {
    width: 120px;
}
.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.green {
    color: #67c23a;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
</style>
